<template>
  <van-nav-bar

      title="签到"
      left-arrow
      @click-left="$router.back()"
  />

  <div>

    <span class="date-display">

      <p> {{ currentDate }}</p>
    </span>


  </div>
  <van-button type="primary" @click="handleCheckin">签到</van-button>


</template>


<script setup>

import {post} from "../../util/request.js";
import {ref} from "vue";


const currentDate = ref(new Date().toLocaleString()); // 使用 ref 定义响应式的当前日期


const handleCheckin = () => {
  post(`sign/check`)
      .then(response => {
        currentDate.value = new Date().toLocaleString();
        alert('签到成功');
      })
      .catch(error => {
        alert('签到失败');
        console.error("签到失败", error)
      });
};

</script>


<style scoped>
.date-display {
  text-align: center;
  margin-top: 20px;
}

.date-picker {
  text-align: center;
  margin-top: 20px;
}
</style>

